package com.icss.controller;

import com.icss.domian.QueryVO;
import com.icss.service.ItemService;
import com.icss.service.RecordService;
import com.icss.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @Autowired
    private ItemService itemService;


    @Autowired
     private   RecordService recordService;
    /*
     * 条件查询:查询所有用户姓名
     *
     * */
    @RequestMapping("findAllUsername")
    @ResponseBody
    public List<QueryVO> findAllUsername(ModelMap map){
        List<QueryVO> userNameList = userService.findAllUserName();
        map.addAttribute("currentPage",0);
        map.addAttribute("UsernameList",userNameList);

        return userNameList;
    }
    /*
     * 条件查询:查询所有用户的车牌号
     *
     * */
    @RequestMapping("findRecordLicenseByUserId")
    @ResponseBody
    public List<QueryVO> findRecordLicenseByUserId(Integer UserId,ModelMap map){

        List<QueryVO> RecordLicens = userService.findRecordLicenseByUserId(UserId);
        System.out.println(RecordLicens);
        map.addAttribute("currentPage",0);
        return RecordLicens;
    }
    /*
     * 条件查询:查询所有违法行为
     *
     * */
    @RequestMapping("findAllIllegalItem")
    @ResponseBody
    public List<QueryVO> findAllIllegalItem(ModelMap map){

        List<QueryVO> itemList = itemService.findAllIllegalItem();
        map.addAttribute("currentPage",0);
        return  itemList;
    }
    /*
     * 条件查询:查询违法行为ById
     *
     * */
    @RequestMapping("findAllIllegalItemByCode")
    @ResponseBody
    public List<QueryVO> findAllIllegalItemByCode(String illegalItemCode,ModelMap map){

        List<QueryVO> itemList = itemService.findIllegalItemById(illegalItemCode);
        map.addAttribute("currentPage",0);
        return  itemList;
    }
    /*
    * 查找所有用户数据
    *
    * */

    @RequestMapping("findAllUserIllega")
    public String findAllUserIllega(ModelMap map){
     List<QueryVO> queryVOList=  userService.findAllUserIllega();
     map.addAttribute("users",queryVOList);
     return "show";
    }

    /**
     * 查询所有违法记录的人
     * @param map
     * @return
     */
    @RequestMapping("findAllIllegalItem1")
    public String findAllIllegalItem1(ModelMap map){
        List<QueryVO> itemList = itemService.findAllIllegalItem();
        map.addAttribute("currentPage",itemList);
        return "showillega";
    }

}
